package com.czxy.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.czxy.dao.SysPermissionMapper;
import com.czxy.dao.SysRoleMapper;
import com.czxy.rbac.SysRole;
import com.czxy.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {
    @Autowired
    private SysPermissionMapper permissionMapper;

    @Override
    public SysRole getById(Integer roleId) {
        SysRole role = baseMapper.selectById(roleId);
        //查找permIds
        List<Integer> permIds = permissionMapper.findPermIdByRoleId(roleId);
        role.setPermIds(permIds);
        return role;
    }
}